use serde::Deserialize;

/// 电子邮件配置
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct EmailConfig {
    /// 与地址关联的名称
    name: Option<String>,
    /// 邮箱服务器的域名
    domain: String,
    /// 用户名
    username: String,
    /// 密码
    password: String,
    /// 端口号
    port: Option<u16>,
}

impl EmailConfig {
    pub fn name(&self) -> Option<&str> {
        self.name.as_deref()
    }
    pub fn domain(&self) -> &str {
        &self.domain
    }
    pub fn username(&self) -> &str {
        &self.username
    }

    pub fn password(&self) -> &str {
        &self.password
    }

    pub fn port(&self) -> u16 {
        self.port.unwrap_or(465)
    }
}
